﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace dzs.Web.Outstorage
{
    public partial class ListEmergency : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            if (Session["login"] != null)
            {
                DataSet ds = Session["login"] as DataSet;
                int user_id = Convert.ToInt32(ds.Tables[0].Rows[0]["user_id"].ToString());

                string strWhere = " user_id=" + user_id;

                if (!string.IsNullOrEmpty(txt_material.Text))
                {
                    strWhere += " and material like '%"+txt_material.Text+"%' ";
                }
                if (!string.IsNullOrEmpty(txt_projectName.Text))
                {
                    strWhere += " and sourceProjectName like '%" + txt_projectName.Text + "%' ";
                }

                DataSet ds_em = new dzs.BLL.emergencyOut().GetList(strWhere);

                this.GridView1.DataSource = ds_em;
                this.GridView1.DataBind();
            }
           

        }
        //查询
        protected void Button1_Click(object sender, EventArgs e)
        {
            Bind();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "lbn_print")
            {
                string emergencyNo = e.CommandArgument.ToString();

                if (!string.IsNullOrEmpty(emergencyNo))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>OpenPopWin('PrintEmergency.aspx?emergencyNo=" + emergencyNo + "','600px','800px');</script>");
                }
                
            }
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.GridView1.PageIndex = e.NewPageIndex;
            Bind();
        }
    }
}